<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<title>CryptoFunctions (POI API Documentation)</title>
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="CryptoFunctions (POI API Documentation)";
    }
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!--   -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/CryptoFunctions.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/poi/poifs/crypt/CipherProvider.html" title="enum in org.apache.poi.poifs.crypt"><span class="strong">PREV CLASS</span></a></li>
<li><a href="../../../../../org/apache/poi/poifs/crypt/DataSpaceMapUtils.html" title="class in org.apache.poi.poifs.crypt"><span class="strong">NEXT CLASS</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/poi/poifs/crypt/CryptoFunctions.html" target="_top">FRAMES</a></li>
<li><a href="CryptoFunctions.html" target="_top">NO FRAMES</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>SUMMARY:&nbsp;</li>
<li>NESTED&nbsp;|&nbsp;</li>
<li>FIELD&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">CONSTR</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">METHOD</a></li>
</ul>
<ul class="subNavList">
<li>DETAIL:&nbsp;</li>
<li>FIELD&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">CONSTR</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">METHOD</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!--   -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<p class="subTitle">org.apache.poi.poifs.crypt</p>
<h2 title="Class CryptoFunctions" class="title">Class CryptoFunctions</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.apache.poi.poifs.crypt.CryptoFunctions</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <strong>CryptoFunctions</strong>
extends java.lang.Object</pre>
<div class="block">Helper functions used for standard and agile encryption</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!--   -->
</a>
<h3>Constructor Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#CryptoFunctions()">CryptoFunctions</a></strong>()</code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!--   -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static byte[]</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#createXorArray1(java.lang.String)">createXorArray1</a></strong>(java.lang.String&nbsp;password)</code>
<div class="block">Creates an byte array for xor obfuscation (method 1)</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#createXorKey1(java.lang.String)">createXorKey1</a></strong>(java.lang.String&nbsp;password)</code>
<div class="block">Create the xor key for xor obfuscation, which is used to create the xor array (method 1)</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#createXorVerifier1(java.lang.String)">createXorVerifier1</a></strong>(java.lang.String&nbsp;password)</code>
<div class="block">Create the verifier for xor obfuscation (method 1)</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#createXorVerifier2(java.lang.String)">createXorVerifier2</a></strong>(java.lang.String&nbsp;password)</code>
<div class="block">This method generates the xor verifier for word documents &lt; 2007 (method 2).</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static byte[]</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#generateIv(org.apache.poi.poifs.crypt.HashAlgorithm, byte[], byte[], int)">generateIv</a></strong>(<a href="../../../../../org/apache/poi/poifs/crypt/HashAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">HashAlgorithm</a>&nbsp;hashAlgorithm,
          byte[]&nbsp;salt,
          byte[]&nbsp;blockKey,
          int&nbsp;blockSize)</code>
<div class="block">2.3.4.12 Initialization Vector Generation (Agile Encryption)
 
 Initialization vectors are used in all cases for agile encryption.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static byte[]</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#generateKey(byte[], org.apache.poi.poifs.crypt.HashAlgorithm, byte[], int)">generateKey</a></strong>(byte[]&nbsp;passwordHash,
           <a href="../../../../../org/apache/poi/poifs/crypt/HashAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">HashAlgorithm</a>&nbsp;hashAlgorithm,
           byte[]&nbsp;blockKey,
           int&nbsp;keySize)</code>
<div class="block">2.3.4.11 Encryption Key Generation (Agile Encryption)
 
 ...</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static byte[]</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#getBlock0(byte[], int)">getBlock0</a></strong>(byte[]&nbsp;hash,
         int&nbsp;size)</code>
<div class="block">Returns a new byte array with a truncated to the given size.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static byte[]</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#getBlock36(byte[], int)">getBlock36</a></strong>(byte[]&nbsp;hash,
          int&nbsp;size)</code>
<div class="block">Returns a new byte array with a truncated to the given size.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static javax.crypto.Cipher</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#getCipher(java.security.Key, org.apache.poi.poifs.crypt.CipherAlgorithm, org.apache.poi.poifs.crypt.ChainingMode, byte[], int, java.lang.String)">getCipher</a></strong>(java.security.Key&nbsp;key,
         <a href="../../../../../org/apache/poi/poifs/crypt/CipherAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">CipherAlgorithm</a>&nbsp;cipherAlgorithm,
         <a href="../../../../../org/apache/poi/poifs/crypt/ChainingMode.html" title="enum in org.apache.poi.poifs.crypt">ChainingMode</a>&nbsp;chain,
         byte[]&nbsp;vec,
         int&nbsp;cipherMode,
         java.lang.String&nbsp;padding)</code>
<div class="block">Initialize a new cipher object with the given cipher properties
 If the given algorithm is not implemented in the JCE, it will try to load it from the bouncy castle
 provider.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static javax.crypto.Cipher</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#getCipher(javax.crypto.SecretKey, org.apache.poi.poifs.crypt.CipherAlgorithm, org.apache.poi.poifs.crypt.ChainingMode, byte[], int)">getCipher</a></strong>(javax.crypto.SecretKey&nbsp;key,
         <a href="../../../../../org/apache/poi/poifs/crypt/CipherAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">CipherAlgorithm</a>&nbsp;cipherAlgorithm,
         <a href="../../../../../org/apache/poi/poifs/crypt/ChainingMode.html" title="enum in org.apache.poi.poifs.crypt">ChainingMode</a>&nbsp;chain,
         byte[]&nbsp;vec,
         int&nbsp;cipherMode)</code>&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static javax.crypto.Mac</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#getMac(org.apache.poi.poifs.crypt.HashAlgorithm)">getMac</a></strong>(<a href="../../../../../org/apache/poi/poifs/crypt/HashAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">HashAlgorithm</a>&nbsp;hashAlgorithm)</code>&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.security.MessageDigest</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#getMessageDigest(org.apache.poi.poifs.crypt.HashAlgorithm)">getMessageDigest</a></strong>(<a href="../../../../../org/apache/poi/poifs/crypt/HashAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">HashAlgorithm</a>&nbsp;hashAlgorithm)</code>&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static byte[]</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#getUtf16LeString(java.lang.String)">getUtf16LeString</a></strong>(java.lang.String&nbsp;str)</code>&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static byte[]</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#hashPassword(java.lang.String, org.apache.poi.poifs.crypt.HashAlgorithm, byte[], int)">hashPassword</a></strong>(java.lang.String&nbsp;password,
            <a href="../../../../../org/apache/poi/poifs/crypt/HashAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">HashAlgorithm</a>&nbsp;hashAlgorithm,
            byte[]&nbsp;salt,
            int&nbsp;spinCount)</code>
<div class="block">2.3.4.7 ECMA-376 Document Encryption Key Generation (Standard Encryption)
 2.3.4.11 Encryption Key Generation (Agile Encryption)
 
 The encryption key for ECMA-376 document encryption [ECMA-376] using agile encryption MUST be 
 generated by using the following method, which is derived from PKCS #5: Password-Based
 Cryptography Version 2.0 [RFC2898].</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static byte[]</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#hashPassword(java.lang.String, org.apache.poi.poifs.crypt.HashAlgorithm, byte[], int, boolean)">hashPassword</a></strong>(java.lang.String&nbsp;password,
            <a href="../../../../../org/apache/poi/poifs/crypt/HashAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">HashAlgorithm</a>&nbsp;hashAlgorithm,
            byte[]&nbsp;salt,
            int&nbsp;spinCount,
            boolean&nbsp;iteratorFirst)</code>
<div class="block">Generalized method for read and write protection hash generation.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#registerBouncyCastle()">registerBouncyCastle</a></strong>()</code>&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#xorHashPassword(java.lang.String)">xorHashPassword</a></strong>(java.lang.String&nbsp;password)</code>
<div class="block">This method generates the xored-hashed password for word documents &lt; 2007.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#xorHashPasswordReversed(java.lang.String)">xorHashPasswordReversed</a></strong>(java.lang.String&nbsp;password)</code>
<div class="block">Convenience function which returns the reversed xored-hashed password for further 
 processing in word documents 2007 and newer, which utilize a real hashing algorithm like sha1.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!--   -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!--   -->
</a>
<h3>Constructor Detail</h3>
<a name="CryptoFunctions()">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>CryptoFunctions</h4>
<pre>public&nbsp;CryptoFunctions()</pre>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!--   -->
</a>
<h3>Method Detail</h3>
<a name="hashPassword(java.lang.String, org.apache.poi.poifs.crypt.HashAlgorithm, byte[], int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hashPassword</h4>
<pre>public static&nbsp;byte[]&nbsp;hashPassword(java.lang.String&nbsp;password,
                  <a href="../../../../../org/apache/poi/poifs/crypt/HashAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">HashAlgorithm</a>&nbsp;hashAlgorithm,
                  byte[]&nbsp;salt,
                  int&nbsp;spinCount)</pre>
<div class="block">2.3.4.7 ECMA-376 Document Encryption Key Generation (Standard Encryption)
 2.3.4.11 Encryption Key Generation (Agile Encryption)
 
 The encryption key for ECMA-376 document encryption [ECMA-376] using agile encryption MUST be 
 generated by using the following method, which is derived from PKCS #5: Password-Based
 Cryptography Version 2.0 [RFC2898].
 
 Let H() be a hashing algorithm as determined by the PasswordKeyEncryptor.hashAlgorithm
 element, H_n be the hash data of the n-th iteration, and a plus sign (+) represent concatenation. The
 password MUST be provided as an array of Unicode characters. Limitations on the length of the
 password and the characters used by the password are implementation-dependent. The initial
 password hash is generated as follows:
 
 - H_0 = H(salt + password)
 
 The salt used MUST be generated randomly. The salt MUST be stored in the
 PasswordKeyEncryptor.saltValue element contained within the \EncryptionInfo stream (1) as
 specified in section 2.3.4.10. The hash is then iterated by using the following approach:
 
 - H_n = H(iterator + H_n-1)
 
 where iterator is an unsigned 32-bit value that is initially set to 0x00000000 and then incremented
 monotonically on each iteration until PasswordKey.spinCount iterations have been performed.
 The value of iterator on the last iteration MUST be one less than PasswordKey.spinCount.
 
 For POI, H_final will be calculated by <a href="../../../../../org/apache/poi/poifs/crypt/CryptoFunctions.html#generateKey(byte[], org.apache.poi.poifs.crypt.HashAlgorithm, byte[], int)"><code>generateKey(byte[],HashAlgorithm,byte[],int)</code></a></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>password</code> - </dd><dd><code>hashAlgorithm</code> - </dd><dd><code>salt</code> - </dd><dd><code>spinCount</code> - </dd>
<dt><span class="strong">Returns:</span></dt><dd>the hashed password</dd></dl>
</li>
</ul>
<a name="hashPassword(java.lang.String, org.apache.poi.poifs.crypt.HashAlgorithm, byte[], int, boolean)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hashPassword</h4>
<pre>public static&nbsp;byte[]&nbsp;hashPassword(java.lang.String&nbsp;password,
                  <a href="../../../../../org/apache/poi/poifs/crypt/HashAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">HashAlgorithm</a>&nbsp;hashAlgorithm,
                  byte[]&nbsp;salt,
                  int&nbsp;spinCount,
                  boolean&nbsp;iteratorFirst)</pre>
<div class="block">Generalized method for read and write protection hash generation.
 The difference is, read protection uses the order iterator then hash in the hash loop, whereas write protection
 uses first the last hash value and then the current iterator value</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>password</code> - </dd><dd><code>hashAlgorithm</code> - </dd><dd><code>salt</code> - </dd><dd><code>spinCount</code> - </dd><dd><code>iteratorFirst</code> - if true, the iterator is hashed before the n-1 hash value,
        if false the n-1 hash value is applied first</dd>
<dt><span class="strong">Returns:</span></dt><dd>the hashed password</dd></dl>
</li>
</ul>
<a name="generateIv(org.apache.poi.poifs.crypt.HashAlgorithm, byte[], byte[], int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>generateIv</h4>
<pre>public static&nbsp;byte[]&nbsp;generateIv(<a href="../../../../../org/apache/poi/poifs/crypt/HashAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">HashAlgorithm</a>&nbsp;hashAlgorithm,
                byte[]&nbsp;salt,
                byte[]&nbsp;blockKey,
                int&nbsp;blockSize)</pre>
<div class="block">2.3.4.12 Initialization Vector Generation (Agile Encryption)
 
 Initialization vectors are used in all cases for agile encryption. An initialization vector MUST be
 generated by using the following method, where H() is a hash function that MUST be the same as
 specified in section 2.3.4.11 and a plus sign (+) represents concatenation:
 1. If a blockKey is provided, let IV be a hash of the KeySalt and the following value:
    blockKey: IV = H(KeySalt + blockKey)
 2. If a blockKey is not provided, let IV be equal to the following value:
    KeySalt:IV = KeySalt.
 3. If the number of bytes in the value of IV is less than the the value of the blockSize attribute
    corresponding to the cipherAlgorithm attribute, pad the array of bytes by appending 0x36 until
    the array is blockSize bytes. If the array of bytes is larger than blockSize bytes, truncate the
    array to blockSize bytes.</div>
</li>
</ul>
<a name="generateKey(byte[], org.apache.poi.poifs.crypt.HashAlgorithm, byte[], int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>generateKey</h4>
<pre>public static&nbsp;byte[]&nbsp;generateKey(byte[]&nbsp;passwordHash,
                 <a href="../../../../../org/apache/poi/poifs/crypt/HashAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">HashAlgorithm</a>&nbsp;hashAlgorithm,
                 byte[]&nbsp;blockKey,
                 int&nbsp;keySize)</pre>
<div class="block">2.3.4.11 Encryption Key Generation (Agile Encryption)
 
 ... continued ...
 
 The final hash data that is used for an encryption key is then generated by using the following
 method:
 
 - H_final = H(H_n + blockKey)
 
 where blockKey represents an array of bytes used to prevent two different blocks from encrypting
 to the same cipher text.
 
 If the size of the resulting H_final is smaller than that of PasswordKeyEncryptor.keyBits, the key
 MUST be padded by appending bytes with a value of 0x36. If the hash value is larger in size than
 PasswordKeyEncryptor.keyBits, the key is obtained by truncating the hash value.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>passwordHash</code> - </dd><dd><code>hashAlgorithm</code> - </dd><dd><code>blockKey</code> - </dd><dd><code>keySize</code> - </dd>
<dt><span class="strong">Returns:</span></dt><dd>intermediate key</dd></dl>
</li>
</ul>
<a name="getCipher(javax.crypto.SecretKey, org.apache.poi.poifs.crypt.CipherAlgorithm, org.apache.poi.poifs.crypt.ChainingMode, byte[], int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getCipher</h4>
<pre>public static&nbsp;javax.crypto.Cipher&nbsp;getCipher(javax.crypto.SecretKey&nbsp;key,
                            <a href="../../../../../org/apache/poi/poifs/crypt/CipherAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">CipherAlgorithm</a>&nbsp;cipherAlgorithm,
                            <a href="../../../../../org/apache/poi/poifs/crypt/ChainingMode.html" title="enum in org.apache.poi.poifs.crypt">ChainingMode</a>&nbsp;chain,
                            byte[]&nbsp;vec,
                            int&nbsp;cipherMode)</pre>
</li>
</ul>
<a name="getCipher(java.security.Key, org.apache.poi.poifs.crypt.CipherAlgorithm, org.apache.poi.poifs.crypt.ChainingMode, byte[], int, java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getCipher</h4>
<pre>public static&nbsp;javax.crypto.Cipher&nbsp;getCipher(java.security.Key&nbsp;key,
                            <a href="../../../../../org/apache/poi/poifs/crypt/CipherAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">CipherAlgorithm</a>&nbsp;cipherAlgorithm,
                            <a href="../../../../../org/apache/poi/poifs/crypt/ChainingMode.html" title="enum in org.apache.poi.poifs.crypt">ChainingMode</a>&nbsp;chain,
                            byte[]&nbsp;vec,
                            int&nbsp;cipherMode,
                            java.lang.String&nbsp;padding)</pre>
<div class="block">Initialize a new cipher object with the given cipher properties
 If the given algorithm is not implemented in the JCE, it will try to load it from the bouncy castle
 provider.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>key</code> - the secrect key</dd><dd><code>cipherAlgorithm</code> - the cipher algorithm</dd><dd><code>chain</code> - the chaining mode</dd><dd><code>vec</code> - the initialization vector (IV), can be null</dd><dd><code>cipherMode</code> - Cipher.DECRYPT_MODE or Cipher.ENCRYPT_MODE</dd><dd><code>padding</code> - </dd>
<dt><span class="strong">Returns:</span></dt><dd>the requested cipher</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.security.GeneralSecurityException</code></dd>
<dd><code><a href="../../../../../org/apache/poi/EncryptedDocumentException.html" title="class in org.apache.poi">EncryptedDocumentException</a></code> - if the initialization failed or if an algorithm was specified,
   which depends on a missing bouncy castle provider</dd></dl>
</li>
</ul>
<a name="getBlock36(byte[], int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getBlock36</h4>
<pre>public static&nbsp;byte[]&nbsp;getBlock36(byte[]&nbsp;hash,
                int&nbsp;size)</pre>
<div class="block">Returns a new byte array with a truncated to the given size. 
 If the hash has less then size bytes, it will be filled with 0x36-bytes</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>hash</code> - the to be truncated/filled hash byte array</dd><dd><code>size</code> - the size of the returned byte array</dd>
<dt><span class="strong">Returns:</span></dt><dd>the padded hash</dd></dl>
</li>
</ul>
<a name="getBlock0(byte[], int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getBlock0</h4>
<pre>public static&nbsp;byte[]&nbsp;getBlock0(byte[]&nbsp;hash,
               int&nbsp;size)</pre>
<div class="block">Returns a new byte array with a truncated to the given size. 
 If the hash has less then size bytes, it will be filled with 0-bytes</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>hash</code> - the to be truncated/filled hash byte array</dd><dd><code>size</code> - the size of the returned byte array</dd>
<dt><span class="strong">Returns:</span></dt><dd>the padded hash</dd></dl>
</li>
</ul>
<a name="getUtf16LeString(java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getUtf16LeString</h4>
<pre>public static&nbsp;byte[]&nbsp;getUtf16LeString(java.lang.String&nbsp;str)</pre>
</li>
</ul>
<a name="getMessageDigest(org.apache.poi.poifs.crypt.HashAlgorithm)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getMessageDigest</h4>
<pre>public static&nbsp;java.security.MessageDigest&nbsp;getMessageDigest(<a href="../../../../../org/apache/poi/poifs/crypt/HashAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">HashAlgorithm</a>&nbsp;hashAlgorithm)</pre>
</li>
</ul>
<a name="getMac(org.apache.poi.poifs.crypt.HashAlgorithm)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getMac</h4>
<pre>public static&nbsp;javax.crypto.Mac&nbsp;getMac(<a href="../../../../../org/apache/poi/poifs/crypt/HashAlgorithm.html" title="enum in org.apache.poi.poifs.crypt">HashAlgorithm</a>&nbsp;hashAlgorithm)</pre>
</li>
</ul>
<a name="registerBouncyCastle()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>registerBouncyCastle</h4>
<pre>public static&nbsp;void&nbsp;registerBouncyCastle()</pre>
</li>
</ul>
<a name="createXorVerifier2(java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>createXorVerifier2</h4>
<pre>public static&nbsp;int&nbsp;createXorVerifier2(java.lang.String&nbsp;password)</pre>
<div class="block">This method generates the xor verifier for word documents &lt; 2007 (method 2).
 Its output will be used as password input for the newer word generations which
 utilize a real hashing algorithm like sha1.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>password</code> - the password</dd>
<dt><span class="strong">Returns:</span></dt><dd>the hashed password</dd><dt><span class="strong">See Also:</span></dt><dd><a href="http://msdn.microsoft.com/en-us/library/dd905229.aspx">2.3.7.4 Binary Document Password Verifier Derivation Method 2</a>, 
<a href="http://blogs.msdn.com/b/vsod/archive/2010/04/05/how-to-set-the-editing-restrictions-in-word-using-open-xml-sdk-2-0.aspx">How to set the editing restrictions in Word using Open XML SDK 2.0</a>, 
<a href="http://www.aspose.com/blogs/aspose-blogs/vladimir-averkin/archive/2007/08/20/funny-how-the-new-powerful-cryptography-implemented-in-word-2007-turns-it-into-a-perfect-tool-for-document-password-removal.html">Funny: How the new powerful cryptography implemented in Word 2007 turns it into a perfect tool for document password removal.</a></dd></dl>
</li>
</ul>
<a name="xorHashPassword(java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>xorHashPassword</h4>
<pre>public static&nbsp;java.lang.String&nbsp;xorHashPassword(java.lang.String&nbsp;password)</pre>
<div class="block">This method generates the xored-hashed password for word documents &lt; 2007.</div>
</li>
</ul>
<a name="xorHashPasswordReversed(java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>xorHashPasswordReversed</h4>
<pre>public static&nbsp;java.lang.String&nbsp;xorHashPasswordReversed(java.lang.String&nbsp;password)</pre>
<div class="block">Convenience function which returns the reversed xored-hashed password for further 
 processing in word documents 2007 and newer, which utilize a real hashing algorithm like sha1.</div>
</li>
</ul>
<a name="createXorVerifier1(java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>createXorVerifier1</h4>
<pre>public static&nbsp;int&nbsp;createXorVerifier1(java.lang.String&nbsp;password)</pre>
<div class="block">Create the verifier for xor obfuscation (method 1)</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>password</code> - the password</dd>
<dt><span class="strong">Returns:</span></dt><dd>the verifier (actually a short value)</dd><dt><span class="strong">See Also:</span></dt><dd><a href="http://msdn.microsoft.com/en-us/library/dd926947.aspx">2.3.7.1 Binary Document Password Verifier Derivation Method 1</a>, 
<a href="http://msdn.microsoft.com/en-us/library/dd905229.aspx">2.3.7.4 Binary Document Password Verifier Derivation Method 2</a></dd></dl>
</li>
</ul>
<a name="createXorKey1(java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>createXorKey1</h4>
<pre>public static&nbsp;int&nbsp;createXorKey1(java.lang.String&nbsp;password)</pre>
<div class="block">Create the xor key for xor obfuscation, which is used to create the xor array (method 1)</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>password</code> - the password</dd>
<dt><span class="strong">Returns:</span></dt><dd>the xor key</dd><dt><span class="strong">See Also:</span></dt><dd><a href="http://msdn.microsoft.com/en-us/library/dd924704.aspx">2.3.7.2 Binary Document XOR Array Initialization Method 1</a>, 
<a href="http://msdn.microsoft.com/en-us/library/dd905229.aspx">2.3.7.4 Binary Document Password Verifier Derivation Method 2</a></dd></dl>
</li>
</ul>
<a name="createXorArray1(java.lang.String)">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>createXorArray1</h4>
<pre>public static&nbsp;byte[]&nbsp;createXorArray1(java.lang.String&nbsp;password)</pre>
<div class="block">Creates an byte array for xor obfuscation (method 1)</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>password</code> - the password</dd>
<dt><span class="strong">Returns:</span></dt><dd>the byte array for xor obfuscation</dd><dt><span class="strong">See Also:</span></dt><dd><a href="http://msdn.microsoft.com/en-us/library/dd924704.aspx">2.3.7.2 Binary Document XOR Array Initialization Method 1</a>, 
<a href="http://docs.libreoffice.org/oox/html/binarycodec_8cxx_source.html">Libre Office implementation</a></dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!--   -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/CryptoFunctions.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/poi/poifs/crypt/CipherProvider.html" title="enum in org.apache.poi.poifs.crypt"><span class="strong">PREV CLASS</span></a></li>
<li><a href="../../../../../org/apache/poi/poifs/crypt/DataSpaceMapUtils.html" title="class in org.apache.poi.poifs.crypt"><span class="strong">NEXT CLASS</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/poi/poifs/crypt/CryptoFunctions.html" target="_top">FRAMES</a></li>
<li><a href="CryptoFunctions.html" target="_top">NO FRAMES</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>SUMMARY:&nbsp;</li>
<li>NESTED&nbsp;|&nbsp;</li>
<li>FIELD&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">CONSTR</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">METHOD</a></li>
</ul>
<ul class="subNavList">
<li>DETAIL:&nbsp;</li>
<li>FIELD&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">CONSTR</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">METHOD</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!--   -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>
                <i>Copyright 2014 The Apache Software Foundation or
        its licensors, as applicable.</i>
            </small></p>
</body>
</html>
